import service from '@/api/service'
import type { UserDto, UserVo } from '@/type/User'
import type { Page, PageQuery } from '@/type/common/list-types'

const mapping = 'user'

/** 条件分页查询用户列表 */
export const userListApi = (pageQuery: PageQuery) =>
  service.post<Page<UserVo[]>>(`${mapping}/page`, pageQuery)

/** 根据用户编号查询用户详细信息 */
export const userInfoApi = (id: string) => service.get<UserVo>(`${mapping}/${id}`)

/** 根据用户编号保存用户信息 */
export const updateUserApi = (id: string, userInfo: UserDto) => service.post(`${mapping}/${id}`, userInfo)

/** 新增用户 */
export const addUserApi = (userInfo: UserDto) => service.put(`${mapping}`, userInfo)

/** 根据用户编号查询角色列表 */
export const userRoleListApi = (userId: string) => service.get<string>(`${mapping}/role/${userId}`)

/** 保存用户所属角色列表 */
export const saveUserRoleApi = (userId: string, roleId: string[]) =>
  service.post(`${mapping}/role/${userId}`, roleId)


// /* 导出用户列表 */
// export const exportUserApi = (
//   size: number,
//   current: number,
//   filter: {
//     exportCol: Array<UnwrapRefSimple<string>>
//     gmtCreateStart: undefined
//     modifyBy: undefined
//     createBy: undefined
//     nickname: undefined
//     orderBy: undefined
//     gmtCreateEnd: undefined
//     email: undefined
//     username: undefined
//   }
// ) => service.download(`${mapping}/export/${size}/${current}`, filter)